#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll a=0;
  ll b=0;
  cin>>a>>b;
  ll ret=0;
  ll y=1;
  ll count=0;
  for(ll i=0;i<b;++i)
  {
    y*=a;
  }
  for(ll i=1;i<y;++i)
  {
    bool check=false;
    for (ll c = 2; c <= i && c <= y; ++c) 
    { 
    if (i % c == 0 && y % c == 0) 
    {     
        check = true;
        break;
    }
    }
    if(!check)
    {
      ret++;
    }
  }
  cout<<ret%998244353;
  return 0;
}
